//获取应用实例
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    areaList: [],
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  },
  //通过微信添加地址
  wxAddress: function () {
    var that = this;
    wx.chooseAddress({
      success: function (res) {
        var address = {
          "name": res.userName,
          "phone": res.telNumber,
          "province": res.provinceName,
          "city": res.cityName,
          "county": res.countyName,
          "detailInfo": res.detailInfo,
        };
        //获取到的地址存到data里的areaList中
        if (that.data.areaList == null) {
          that.setData({
            areaList: address
          });
        } else {
          that.setData({
            areaList: that.data.areaList.concat(address)
          });
        }
        console.log(areaList);
      },
      fail: () => {
        this.openConfirm()   // 如果获取地址权限失败，弹出确认弹窗，让用户选择是否要打开设置，手动去开权限
      }
    })
  },
})